package org.dizena.modules.master.web;

import lombok.extern.slf4j.Slf4j;
import org.dizena.base.shiro.SessionUserUtil;
import org.dizena.modules.master.avo.MenuVo;
import org.dizena.modules.master.bean.User;
import org.dizena.modules.master.service.WebRootService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Able
 */
@Slf4j
@Controller
@RequestMapping({"master"})
public class WebRootController
{

    @Resource
    private WebRootService service;

    @RequestMapping({"", "/"})
    public String root(Model m)
    {
        User loginUser = SessionUserUtil.getSessionUser();
        if (null == loginUser)
        {
            return "base/login";
        }
        m.addAttribute("cuser", loginUser);
        List<MenuVo> menus = service.getUserRess();
        m.addAttribute("menus", menus);
        return "master/main";
    }

    @RequestMapping({"info"})
    public String info(Model m)
    {
        return "base/info";
    }

}
